package o;

import com.huawei.appgallery.festivalanimation.particle.modifiers.SizeModifier;
import java.util.Arrays;
import o.eh.d;

public class eb {
    private int[] ʻ = new int[this.ˋ];
    private float[] ʼ = new float[this.ˋ];
    private int ʽ = -1;
    private final ec ˊ;
    private int ˋ = 8;
    private boolean ˋॱ = false;
    int ˎ = 0;
    private eh ˏ = null;
    private final ee ॱ;
    private int ॱॱ = -1;
    private int[] ᐝ = new int[this.ˋ];

    eb(ec ecVar, ee eeVar) {
        this.ˊ = ecVar;
        this.ॱ = eeVar;
    }

    public final void ॱ(eh ehVar, float f) {
        if (f == 0.0f) {
            ˎ(ehVar, true);
        } else if (this.ʽ == -1) {
            this.ʽ = 0;
            this.ʼ[this.ʽ] = f;
            this.ᐝ[this.ʽ] = ehVar.ˋ;
            this.ʻ[this.ʽ] = -1;
            ehVar.ᐝ++;
            ehVar.ॱ(this.ˊ);
            this.ˎ++;
            if (!this.ˋॱ) {
                this.ॱॱ++;
                if (this.ॱॱ >= this.ᐝ.length) {
                    this.ˋॱ = true;
                    this.ॱॱ = this.ᐝ.length - 1;
                }
            }
        } else {
            int i = this.ʽ;
            int i2 = 0;
            int i3 = -1;
            while (i != -1 && i2 < this.ˎ) {
                if (this.ᐝ[i] == ehVar.ˋ) {
                    this.ʼ[i] = f;
                    return;
                }
                if (this.ᐝ[i] < ehVar.ˋ) {
                    i3 = i;
                }
                i2++;
                i = this.ʻ[i];
            }
            i = this.ॱॱ + 1;
            if (this.ˋॱ) {
                if (this.ᐝ[this.ॱॱ] == -1) {
                    i = this.ॱॱ;
                } else {
                    i = this.ᐝ.length;
                }
            }
            if (i >= this.ᐝ.length && this.ˎ < this.ᐝ.length) {
                for (i2 = 0; i2 < this.ᐝ.length; i2++) {
                    if (this.ᐝ[i2] == -1) {
                        i = i2;
                        break;
                    }
                }
            }
            if (i >= this.ᐝ.length) {
                i = this.ᐝ.length;
                this.ˋ *= 2;
                this.ˋॱ = false;
                this.ॱॱ = i - 1;
                this.ʼ = Arrays.copyOf(this.ʼ, this.ˋ);
                this.ᐝ = Arrays.copyOf(this.ᐝ, this.ˋ);
                this.ʻ = Arrays.copyOf(this.ʻ, this.ˋ);
            }
            this.ᐝ[i] = ehVar.ˋ;
            this.ʼ[i] = f;
            if (i3 != -1) {
                this.ʻ[i] = this.ʻ[i3];
                this.ʻ[i3] = i;
            } else {
                this.ʻ[i] = this.ʽ;
                this.ʽ = i;
            }
            ehVar.ᐝ++;
            ehVar.ॱ(this.ˊ);
            this.ˎ++;
            if (!this.ˋॱ) {
                this.ॱॱ++;
            }
            if (this.ˎ >= this.ᐝ.length) {
                this.ˋॱ = true;
            }
            if (this.ॱॱ >= this.ᐝ.length) {
                this.ˋॱ = true;
                this.ॱॱ = this.ᐝ.length - 1;
            }
        }
    }

    final void ॱ(eh ehVar, float f, boolean z) {
        if (f != 0.0f) {
            if (this.ʽ == -1) {
                this.ʽ = 0;
                this.ʼ[this.ʽ] = f;
                this.ᐝ[this.ʽ] = ehVar.ˋ;
                this.ʻ[this.ʽ] = -1;
                ehVar.ᐝ++;
                ehVar.ॱ(this.ˊ);
                this.ˎ++;
                if (!this.ˋॱ) {
                    this.ॱॱ++;
                    if (this.ॱॱ >= this.ᐝ.length) {
                        this.ˋॱ = true;
                        this.ॱॱ = this.ᐝ.length - 1;
                        return;
                    }
                    return;
                }
                return;
            }
            int i = this.ʽ;
            int i2 = 0;
            int i3 = -1;
            while (i != -1 && i2 < this.ˎ) {
                if (this.ᐝ[i] == ehVar.ˋ) {
                    float[] fArr = this.ʼ;
                    fArr[i] = fArr[i] + f;
                    if (this.ʼ[i] == 0.0f) {
                        if (i == this.ʽ) {
                            this.ʽ = this.ʻ[i];
                        } else {
                            this.ʻ[i3] = this.ʻ[i];
                        }
                        if (z) {
                            ehVar.ˏ(this.ˊ);
                        }
                        if (this.ˋॱ) {
                            this.ॱॱ = i;
                        }
                        ehVar.ᐝ--;
                        this.ˎ--;
                        return;
                    }
                    return;
                }
                if (this.ᐝ[i] < ehVar.ˋ) {
                    i3 = i;
                }
                i2++;
                i = this.ʻ[i];
            }
            i = this.ॱॱ + 1;
            if (this.ˋॱ) {
                if (this.ᐝ[this.ॱॱ] == -1) {
                    i = this.ॱॱ;
                } else {
                    i = this.ᐝ.length;
                }
            }
            if (i >= this.ᐝ.length && this.ˎ < this.ᐝ.length) {
                for (i2 = 0; i2 < this.ᐝ.length; i2++) {
                    if (this.ᐝ[i2] == -1) {
                        i = i2;
                        break;
                    }
                }
            }
            if (i >= this.ᐝ.length) {
                i = this.ᐝ.length;
                this.ˋ *= 2;
                this.ˋॱ = false;
                this.ॱॱ = i - 1;
                this.ʼ = Arrays.copyOf(this.ʼ, this.ˋ);
                this.ᐝ = Arrays.copyOf(this.ᐝ, this.ˋ);
                this.ʻ = Arrays.copyOf(this.ʻ, this.ˋ);
            }
            this.ᐝ[i] = ehVar.ˋ;
            this.ʼ[i] = f;
            if (i3 != -1) {
                this.ʻ[i] = this.ʻ[i3];
                this.ʻ[i3] = i;
            } else {
                this.ʻ[i] = this.ʽ;
                this.ʽ = i;
            }
            ehVar.ᐝ++;
            ehVar.ॱ(this.ˊ);
            this.ˎ++;
            if (!this.ˋॱ) {
                this.ॱॱ++;
            }
            if (this.ॱॱ >= this.ᐝ.length) {
                this.ˋॱ = true;
                this.ॱॱ = this.ᐝ.length - 1;
            }
        }
    }

    public final float ˎ(eh ehVar, boolean z) {
        if (this.ˏ == ehVar) {
            this.ˏ = null;
        }
        if (this.ʽ == -1) {
            return 0.0f;
        }
        int i = this.ʽ;
        int i2 = 0;
        int i3 = -1;
        while (i != -1 && i2 < this.ˎ) {
            if (this.ᐝ[i] == ehVar.ˋ) {
                if (i == this.ʽ) {
                    this.ʽ = this.ʻ[i];
                } else {
                    this.ʻ[i3] = this.ʻ[i];
                }
                if (z) {
                    ehVar.ˏ(this.ˊ);
                }
                ehVar.ᐝ--;
                this.ˎ--;
                this.ᐝ[i] = -1;
                if (this.ˋॱ) {
                    this.ॱॱ = i;
                }
                return this.ʼ[i];
            }
            i2++;
            int i4 = i;
            i = this.ʻ[i];
            i3 = i4;
        }
        return 0.0f;
    }

    public final void ˎ() {
        int i = this.ʽ;
        int i2 = 0;
        while (i != -1 && i2 < this.ˎ) {
            eh ehVar = this.ॱ.ˎ[this.ᐝ[i]];
            if (ehVar != null) {
                ehVar.ˏ(this.ˊ);
            }
            i = this.ʻ[i];
            i2++;
        }
        this.ʽ = -1;
        this.ॱॱ = -1;
        this.ˋॱ = false;
        this.ˎ = 0;
    }

    final boolean ˎ(eh ehVar) {
        if (this.ʽ == -1) {
            return false;
        }
        int i = this.ʽ;
        int i2 = 0;
        while (i != -1 && i2 < this.ˎ) {
            if (this.ᐝ[i] == ehVar.ˋ) {
                return true;
            }
            i = this.ʻ[i];
            i2++;
        }
        return false;
    }

    void ॱ() {
        int i = this.ʽ;
        int i2 = 0;
        while (i != -1 && i2 < this.ˎ) {
            float[] fArr = this.ʼ;
            fArr[i] = fArr[i] * SizeModifier.STABLE_STATE_SCALE;
            i = this.ʻ[i];
            i2++;
        }
    }

    void ˎ(float f) {
        int i = this.ʽ;
        int i2 = 0;
        while (i != -1 && i2 < this.ˎ) {
            float[] fArr = this.ʼ;
            fArr[i] = fArr[i] / f;
            i = this.ʻ[i];
            i2++;
        }
    }

    private boolean ˎ(eh ehVar, ea eaVar) {
        return ehVar.ᐝ <= 1;
    }

    eh ˎ(ea eaVar) {
        eh ehVar = null;
        boolean z = false;
        int i = 0;
        int i2 = this.ʽ;
        float f = 0.0f;
        float f2 = 0.0f;
        eh ehVar2 = null;
        boolean z2 = false;
        while (i2 != -1 && i < this.ˎ) {
            eh ehVar3;
            float f3 = this.ʼ[i2];
            eh ehVar4 = this.ॱ.ˎ[this.ᐝ[i2]];
            if (f3 < 0.0f) {
                if (f3 > (-981668463)) {
                    this.ʼ[i2] = 0.0f;
                    ehVar4.ˏ(this.ˊ);
                    f3 = 0.0f;
                }
            } else if (f3 < 0.001f) {
                this.ʼ[i2] = 0.0f;
                ehVar4.ˏ(this.ˊ);
                f3 = 0.0f;
            }
            if (f3 != 0.0f) {
                if (ehVar4.ʽ == d.UNRESTRICTED) {
                    if (ehVar == null) {
                        z2 = ˎ(ehVar4, eaVar);
                        ehVar3 = ehVar4;
                        ehVar4 = ehVar2;
                    } else if (f2 > f3) {
                        z2 = ˎ(ehVar4, eaVar);
                        ehVar3 = ehVar4;
                        ehVar4 = ehVar2;
                    } else if (!z2 && ˎ(ehVar4, eaVar)) {
                        z2 = true;
                        ehVar3 = ehVar4;
                        ehVar4 = ehVar2;
                    }
                    i++;
                    i2 = this.ʻ[i2];
                    ehVar = ehVar3;
                    ehVar2 = ehVar4;
                    f2 = f3;
                } else if (ehVar == null && f3 < 0.0f) {
                    if (ehVar2 == null) {
                        z = ˎ(ehVar4, eaVar);
                        f = f3;
                        f3 = f2;
                        ehVar3 = ehVar;
                    } else if (f > f3) {
                        z = ˎ(ehVar4, eaVar);
                        f = f3;
                        f3 = f2;
                        ehVar3 = ehVar;
                    } else if (!z && ˎ(ehVar4, eaVar)) {
                        z = true;
                        f = f3;
                        f3 = f2;
                        ehVar3 = ehVar;
                    }
                    i++;
                    i2 = this.ʻ[i2];
                    ehVar = ehVar3;
                    ehVar2 = ehVar4;
                    f2 = f3;
                }
            }
            f3 = f2;
            ehVar4 = ehVar2;
            ehVar3 = ehVar;
            i++;
            i2 = this.ʻ[i2];
            ehVar = ehVar3;
            ehVar2 = ehVar4;
            f2 = f3;
        }
        return ehVar != null ? ehVar : ehVar2;
    }

    final void ˋ(ec ecVar, ec ecVar2, boolean z) {
        int i = this.ʽ;
        int i2 = 0;
        while (i != -1 && i2 < this.ˎ) {
            if (this.ᐝ[i] == ecVar2.ˎ.ˋ) {
                float f = this.ʼ[i];
                ˎ(ecVar2.ˎ, z);
                eb ebVar = ecVar2.ˋ;
                int i3 = ebVar.ʽ;
                i = 0;
                while (i3 != -1 && i < ebVar.ˎ) {
                    ॱ(this.ॱ.ˎ[ebVar.ᐝ[i3]], ebVar.ʼ[i3] * f, z);
                    i3 = ebVar.ʻ[i3];
                    i++;
                }
                ecVar.ˊ += ecVar2.ˊ * f;
                if (z) {
                    ecVar2.ˎ.ˏ(ecVar);
                }
                i = this.ʽ;
                i2 = 0;
            } else {
                i = this.ʻ[i];
                i2++;
            }
        }
    }

    void ˎ(ec ecVar, ec[] ecVarArr) {
        int i = this.ʽ;
        int i2 = 0;
        while (i != -1 && i2 < this.ˎ) {
            eh ehVar = this.ॱ.ˎ[this.ᐝ[i]];
            if (ehVar.ॱ != -1) {
                float f = this.ʼ[i];
                ˎ(ehVar, true);
                ec ecVar2 = ecVarArr[ehVar.ॱ];
                if (!ecVar2.ˏ) {
                    eb ebVar = ecVar2.ˋ;
                    int i3 = ebVar.ʽ;
                    i = 0;
                    while (i3 != -1 && i < ebVar.ˎ) {
                        ॱ(this.ॱ.ˎ[ebVar.ᐝ[i3]], ebVar.ʼ[i3] * f, true);
                        i3 = ebVar.ʻ[i3];
                        i++;
                    }
                }
                ecVar.ˊ += ecVar2.ˊ * f;
                ecVar2.ˎ.ˏ(ecVar);
                i = this.ʽ;
                i2 = 0;
            } else {
                i = this.ʻ[i];
                i2++;
            }
        }
    }

    eh ॱ(boolean[] zArr, eh ehVar) {
        eh ehVar2 = null;
        int i = 0;
        int i2 = this.ʽ;
        float f = 0.0f;
        while (i2 != -1 && i < this.ˎ) {
            eh ehVar3;
            if (this.ʼ[i2] < 0.0f) {
                eh ehVar4 = this.ॱ.ˎ[this.ᐝ[i2]];
                if ((zArr == null || !zArr[ehVar4.ˋ]) && ehVar4 != ehVar && (ehVar4.ʽ == d.SLACK || ehVar4.ʽ == d.ERROR)) {
                    float f2 = this.ʼ[i2];
                    if (f2 < f) {
                        f = f2;
                        ehVar3 = ehVar4;
                        i++;
                        i2 = this.ʻ[i2];
                        ehVar2 = ehVar3;
                    }
                }
            }
            ehVar3 = ehVar2;
            i++;
            i2 = this.ʻ[i2];
            ehVar2 = ehVar3;
        }
        return ehVar2;
    }

    final eh ˊ(int i) {
        int i2 = this.ʽ;
        int i3 = 0;
        while (i2 != -1 && i3 < this.ˎ) {
            if (i3 == i) {
                return this.ॱ.ˎ[this.ᐝ[i2]];
            }
            i2 = this.ʻ[i2];
            i3++;
        }
        return null;
    }

    final float ˋ(int i) {
        int i2 = this.ʽ;
        int i3 = 0;
        while (i2 != -1 && i3 < this.ˎ) {
            if (i3 == i) {
                return this.ʼ[i2];
            }
            i2 = this.ʻ[i2];
            i3++;
        }
        return 0.0f;
    }

    public final float ˊ(eh ehVar) {
        int i = this.ʽ;
        int i2 = 0;
        while (i != -1 && i2 < this.ˎ) {
            if (this.ᐝ[i] == ehVar.ˋ) {
                return this.ʼ[i];
            }
            i = this.ʻ[i];
            i2++;
        }
        return 0.0f;
    }

    public String toString() {
        String str = "";
        int i = this.ʽ;
        int i2 = 0;
        while (i != -1 && i2 < this.ˎ) {
            str = ((str + " -> ") + this.ʼ[i] + " : ") + this.ॱ.ˎ[this.ᐝ[i]];
            i = this.ʻ[i];
            i2++;
        }
        return str;
    }
}
